﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="newsedit.aspx.cs" Inherits="new_edit"
    ValidateRequest="false" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="../css/style.css" rel="stylesheet" type="text/css" />
    <link href="../css/jquery.autocomplete.css" rel="stylesheet" type="text/css" />
    <link href="../css/jquery-ui-1.7.3.custom.css" rel="Stylesheet" type="text/css" />
    <script type="text/javascript" src="../edit/jquery/jquery-1.4.2.min.js"></script>
    <script type="text/javascript" src="../edit/xheditor-zh-cn.src.js"></script>
    <script src="../js/jquery.autocomplete.js" type="text/javascript"  language="javascript"></script>
    <script src="../js/StockSearchData.js" language="javascript" type="text/javascript"></script>
    <script type="text/javascript" defer="defer" src="../My97DatePicker/WdatePicker.js"></script>
    <script src="../js/jquery-ui-1.7.3.custom.min.js"></script>
    <script type="text/javascript" language="javascript">
        var selectValue = new Array();
        $(pageInit);
        function pageInit() {
            $('#txtSummary,').xheditor();
            $("#txtContent").xheditor({ upImgUrl: "../upload/newsUpload.aspx", upImgExt: "jpg,jpeg,gif,png" })
        }
        function submitForm() { $("frmDemo").submit(); }
        $(document).ready(function () {
            $("#txtStock").autocomplete(EALists, {
                max: 10,
                minChars: 0,
                width: 160,
                matchContains: true,
                autoFill: false,
                formatItem: function (row, i, max) {
                    return row._C + " " + row._S + " " + row._N;
                },
                formatMatch: function (row, i, max) {
                    return row._C + " " + row._S + " " + row._N;
                },
                formatResult: function (row) {
                    return row._C;
                }
            });
            function insertUpload(msg) {
                msg = msg[0];
                $("#uploadList").append('<option value="' + msg.id + '">' + msg.localname + '</option>');
            }
            $("#btnBack,#btnBack1").click(function () {
                document.location = "default.aspx";
            })

            $("#btnSelect").click(function () {
                var cbklist = $("#DataList1 input[type=checkbox]");
                var vals = $("#hidSelectValue").val().split(",");

                for (var i = 0; i < vals.length; i++) {
                    for (var j = 0; j < cbklist.length; j++) {
                        if (cbklist[j].value == vals[i]) {
                            cbklist[j].checked = true;
                        }
                    }
                }
                selectValue.length = 0;
                for (var i = 0; i < cbklist.length; i++) {
                    if (cbklist[i].checked) {
                        selectValue[selectValue.length] = $(cbklist[i]).val();
                    }
                }
                $("#dialog").dialog('open');
            })
            $("#dialog").dialog({
                autoOpen: false,
                width: 600,
                buttons: {
                    "取消": function () {
                        var cbklist = $("#DataList1 input[type=checkbox]");
                        for (var i = 0; i < cbklist.length; i++) {
                            cbklist[i].checked = false;
                            for (var j = 0; j < selectValue.length; j++) {
                                if (cbklist[i].value == selectValue[j]) {
                                    cbklist[i].checked = true;
                                }
                            }
                        }
                        $(this).dialog("close");
                    },
                    "确定": function () {
                        var cbklist = $("#DataList1 input[type=checkbox]");
                        var list = "";
                        var x = "";
                        $("#lblSelectType").html('');
                        for (var i = 0; i < cbklist.length; i++) {
                            if (cbklist[i].checked) {
                                list += $(cbklist[i]).parent().children("Label").html() + ",";
                                x += $(cbklist[i]).val() + ",";
                            }
                        }
                        if (x.length == 0) {
                            alert("必须选择一个新闻类型");
                            return;
                        }
                        if (list.length > 0) {
                            list = list.substring(0, list.length - 1);
                        }

                        x = x.substring(0, x.length - 1);
                        $("#hidSelectValue").val(x);

                        $("#lblSelectType").html(list);
                        $(this).dialog("close");
                    }
                }
            })
        })

    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:HiddenField ID="hidSelectValue" runat="server" />
    <div class="button_bar">
        <input type="button" class="common_button" id="btnBack" value="返回"></input>
        <asp:Button ID="btnSave" CssClass="common_button" runat="server" Text="保存" OnClick="btnSave_Click" />
    </div>
    <div>
        <table class="query_form_table">
            <tr>
                <th>
                    新闻类型
                </th>
                <td colspan="3">
                    <asp:DropDownList ID="ddlType" runat="server">
                    </asp:DropDownList>
&nbsp;</td>
            </tr>
            <tr>
                <th>
                    标题
                </th>
                <td colspan="3">
                    <asp:TextBox ID="txtTitle" runat="server" Width="465px" />
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtTitle"
                        Display="Dynamic" ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <th>
                    新闻编号
                </th>
                <td>
                    <asp:TextBox ID="txtNewsId" runat="server" ReadOnly="true" />
                </td>
                <th>
                    新闻来源
                </th>
                <td>
                    <asp:TextBox ID="txtSource" runat="server" />
                </td>
            </tr>
            <tr>
                <th>
                    作者
                </th>
                <td>
                    <asp:TextBox ID="txtAuthor" runat="server" />
                </td>
                <th>
                    相关股票
                </th>
                <td>
                    <asp:TextBox ID="txtStock" runat="server" MaxLength="6" />
                    (000001,000002)</td>
            </tr>
            <tr>
             <th>
                    新闻重要度
                </th>
                <td colspan="3">
                    <asp:DropDownList ID="ddlStep" runat="server">
                        <asp:ListItem Value="0">0</asp:ListItem>
                        <asp:ListItem Value="1">1</asp:ListItem>
                        <asp:ListItem Value="2">2</asp:ListItem>
                        <asp:ListItem Value="3">3</asp:ListItem>
                        <asp:ListItem Value="4">4</asp:ListItem>
                        <asp:ListItem Value="5">5</asp:ListItem>
                        <asp:ListItem Value="6">6</asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <th>
                    关键字
                </th>
                <td colspan="3">
                    <asp:TextBox ID="txtKeyWords" runat="server" Width="382px" />
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtKeyWords"
                        Display="Dynamic" ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <th>
                    图片</th>
                <td colspan="3">
                  <asp:Image ID="Image1" runat="server"  />
                  <asp:FileUpload ID="FileUpload1" runat="server" />
                  <asp:Button ID="Button3" runat="server" CausesValidation="False" 
                      onclick="Button3_Click" Text="上传" />
                </td>
            </tr>
            <tr>
                <th>
                    摘要
                </th>
                <td colspan="3">
                    <asp:TextBox ID="txtSummary" runat="server" Width="80%" Height="113px" TextMode="MultiLine" />
                </td>
            </tr>
            <tr>
                <th>
                    内容
                </th>
                <td colspan="3">
                    <asp:TextBox ID="txtContent" runat="server" Width="80%" Height="300px" TextMode="MultiLine" />
                </td>
            </tr>
        </table>
    </div>
    <div class="button_bar">
        <input type="button" class="common_button" id="btnBack1" value="返回"></input>
        <asp:Button ID="Button2" CssClass="common_button" runat="server" Text="保存" OnClick="btnSave_Click" />
    </div>
    </form>
</body>
</html>
